package com.enzoism.spring.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: enzoism
 * Date: 2020/2/6- 23:34
 */
@Controller
@RequestMapping("/test")
public class TestController {

    @RequestMapping(value = {"/hello"},method = RequestMethod.GET)
    @ResponseBody
    public void sayHello(){
        System.out.println("------------测试接口是否正常（无页面返回）");
    }

    @RequestMapping(value = {"/index"},method = RequestMethod.GET)
    public String index(){
        System.out.println("------------跳转index.jsp");
        return "index";
    }

    @RequestMapping(value = {"/main"},method = RequestMethod.GET)
    public String main(){
        System.out.println("------------这面重定向跳转到main.jsp");
        return "redirect:/main/index";
    }

    @RequestMapping(value = {"/json"},method = RequestMethod.GET)
    @ResponseBody
    public String json(){
        System.out.println("------------测试接收JSON");
        Map<String, String> resultMap = new HashMap<String, String>();
        resultMap.put("key1","init json data");
        return resultMap.toString();
    }
}
